package Job202213;

import java.util.Random;
import java.util.Scanner;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.01.16.19.44
 */
public class Job4 {
    public static void main(String[] args) {
        //猜数字游戏
        Scanner sc=new Scanner(System.in);
        Random r=new Random();
        int m=r.nextInt(100)+1;
        while (true) {
            System.out.println("请输入数字：");
            int g;
            try {
                g = sc.nextInt();
            } catch (Exception e) {
                if ("quit".equals(sc.nextLine())) {
                    break;
                } else {
                    System.out.println("你输入的不正确请重新输入");
                    continue;
                }
            }
            if (g == m) {
                System.out.println("恭喜你猜对了！");
                break;
            }else if(g>m){
                System.out.println("你猜大了");
            }else {
                System.out.println("你猜小了");
            }
        }

    }
}
